package br.com.post.action;

import java.io.Serializable;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.util.ServletContextAware;

import br.com.post.model.User;

import com.opensymphony.xwork2.ActionSupport;

public abstract class SuperAction extends ActionSupport implements Serializable,ServletContextAware,ServletRequestAware,ServletResponseAware {
	
	public static final String USER_SESSION="USER";
	
	private HttpServletResponse response;
	private HttpServletRequest request;
	private ServletContext context;
	
	public User userSession(){
		return request.getSession().getAttribute(USER_SESSION)!=null?(User)request.getSession().getAttribute(USER_SESSION):null; 
	}
	
	@Override
	public void setServletContext(ServletContext context) {
		this.context=context;
		
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.request=request;
		
	}

	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.response=response;
		
	}

	public HttpServletResponse getResponse() {
		return response;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public ServletContext getContext() {
		return context;
	}

}
